package cn.com.bsoft.mobile.model


import cn.net.xyan.blossom.kotlin.NoArg
import cn.net.xyan.blossom.kotlin.StatusAndMessageError
import com.fasterxml.jackson.annotation.JsonFormat
import java.util.*

enum class DeviceType(val value:String){

    Android("Android"),iOS("iOS"),WindowsPhone("WP");

    companion object {
        fun fromString(type:String):DeviceType{
            return when(type){
                Android.value -> Android
                iOS.value -> iOS
                WindowsPhone.value -> WindowsPhone
                else -> throw StatusAndMessageError("未知的设备类型:$type")
            }
        }
    }


}

@NoArg
data class Device(val udid:String,val type:DeviceType){
    /**
     * 设备型号
     */
    var model:String? = null

    /**
     * 生产厂商
     */
    var vendor:String? = null

    /**
     * 操作系统版本
     */
    var osName:String? = null
}

@NoArg
data class App(val appID: String,val type:DeviceType,var title:String?){
    var teamID:String? = null

    var pushHost:String? = null

    var pushKeyID:String? = null

    var pushSecret:String? = null

    var suiteID:String? = null
}

@NoArg
data class LinkUserAppDeviceReq(val username:String,val appID:String){
    lateinit var device:Device
    var codeForNotiyPush:String? = null
}

@NoArg
data class RemoveUserAppDeviceReq(val username:String,val appID:String){
    lateinit var device:Device
    var codeForNotiyPush:String? = null
}

@NoArg
data class QueryAppMessageReq(val username:String){
    var readStatus:Int? = null
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    var begin:Date? = null

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    var end:Date? = null

    var msgID:String? = null
}

@NoArg
class QueryAppVersionReq{
    var nativeID:String? = null
    var type:DeviceType? = null
    var version:String? = null
    var onlyRelease:Boolean? = null

    var page:Int? = null
    var pageSize:Int? = null
}

@NoArg
class SubmitAppVersionReq{
    var nativeID:String? = null
    var title:String? = null
    var type:DeviceType? = null
    var version:String? = null
    var describe:String? = null
    var data:ByteArray? = null
    var enable:Boolean = false
}

@NoArg
class FeedbackReq{
    var username:String? = null
    var body:String? = null
    var archives:MutableList<String> = LinkedList()
}

@NoArg
class QueryFeedbackReq(val username:String){
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    var begin:Date? = null
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    var end:Date? = null
}

@NoArg
class CreateAppMessageReq{
    var user:MutableList<String?> = LinkedList()
    var suite:String? = null
    var title:String? = null
    var body:String? = null
    var contentType:String? = null
    var action:String? = null
    var extra:String? = null
}